﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DrugsShopManagement.DBCLASS;
namespace DrugsShopManagement
{
    public partial class FrmChangePwd : DevExpress.XtraEditors.XtraForm
    {
        public FrmChangePwd()
        {
            InitializeComponent();
        }
        public static string uid = "";
        public static string user_name = "";
        public string user_power = "";
        Operator op = new Operator();
        private void button1_Click(object sender, EventArgs e)
        {

            DataTable dt = new DataTable();
            dt = op.getDataTable("select * from users where user_no='" + FrmLogin.uid + "' and user_pwd='" + txtBoxUserNo.Text.Trim() + "'", "users");
            if (dt.Rows.Count <= 0)
            {
                MessageBox.Show("原密码输入有误，请重新输入！");
                txtBoxUserNo.Text = "";
                txtBoxUserNo.Focus();
                return;
            }
            if (textBox2.Text.Trim() != textBox3.Text.Trim())
            {
                MessageBox.Show("两次输入的新密码不一样，请重新输入！");
                textBox3.Text = "";
                textBox2.Text = "";
                textBox2.Focus();
                return;
            }
            op.ExecuteSql("update users set user_pwd='" + textBox2.Text.Trim() + "' where user_no='" + FrmLogin.uid + "'");
            this.Close();
            MessageBox.Show("密码修改成功！");
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void FrmChangePwd_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmChangePwd_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose();
        }
    }
}
